<script setup>
import { provide, ref } from "vue";
import RoomMsgItem from "./RoomMsgItem.vue";

//1. 顶层组件提供数据
provide("roomData","顶层数据")

//2.传递相应数据
const roomCount = ref(100)
// provide('roomCount',roomCount)


setTimeout(()=>{
    roomCount.value = 1000
},3000)

//3.传递方法
const setRoomCount = () => {
    roomCount.value++
}

provide('roomCount',roomCount)
provide('setRoomCount',setRoomCount)




</script>

<template>
    <div class="name">
        顶层组件
        <RoomMsgItem/>
    </div>
    <button @click="setRoomCount">顶层数据</button>
</template>